﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Workflow.Runtime;
using MyPublisher.Configuration;
using System.Configuration;
using System.Workflow.Activities;
using MyPublisher.Service;
namespace MyPublisher.PublishService
{
    public partial class Service : ServiceBase
    {
        private ServiceHost Host { get; set; }
        public Service()
        {
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                Host = new ServiceHost(typeof(MyPublisher.Service.PublishService));
                Host.Open();
            }
            catch (Exception e)
            {
                throw new ApplicationException("Failed to start service.",e);
            }
        }

        protected override void OnStop()
        {
            try
            {
                if (Host != null && Host.State == CommunicationState.Opened)
                {
                    Host.Close();
                }
            }
            catch (Exception e) { }
        }

        #region debug
        public void DebugOnStart()
        {
            this.OnStart(new string[] { });
        }
        public void DebugOnStop()
        {
            this.OnStop();
        }
        #endregion
    }
}
